Skip to content

fix: automatic create database directory for SQLAlchemy connector#75

Merged
markoceri merged 1 commit intodevfrom
fix/database-folder-not-exists-74
Apr 2, 2026
Merged

fix: automatic create database directory for SQLAlchemy connector#75
markoceri merged 1 commit intodevfrom
fix/database-folder-not-exists-74

Conversation

@markoceri
Copy link
Copy Markdown
Collaborator

Description

Following a bug report #74 , it was identified that the application crashes at startup if the /data/db directory (or any custom SQLite path) does not exist.

While the legacy SQLITE persistence adapter correctly handled directory creation, this logic was accidentally omitted during the migration to the SQLALCHEMY adapter. SQLAlchemy's SQLite engine expects the target directory to exist beforehand, leading to an OperationalError when the path is missing.

Changes

  • Re-implemented the directory presence check within the SQLALCHEMY persistence configuration.
  • Added logic to parse the db_url (specifically for sqlite:/// schemes) to extract the directory path.
  • Used os.makedirs(db_dir, exist_ok=True) to ensure the path is created safely before the repository is initialized.
  • Added debug logging to confirm directory creation during the bootstrap phase.

Testing

  • Deleted the local /data/db folder and verified that the core now creates it automatically on launch.
  • Verified that existing databases are not affected.
  • Tested with both relative and absolute paths in settings.db_path.

This PR closes #74

…tions wen using SQLAlchemy as persistence adapter
@markoceri markoceri self-assigned this Mar 26, 2026
@markoceri markoceri merged commit 88129f6 into dev Apr 2, 2026
@markoceri markoceri deleted the fix/database-folder-not-exists-74 branch April 2, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant